package com.example.backend.controller;


import com.example.backend.entity.Car;
import com.example.backend.entity.DingDanDetail;
import com.example.backend.entity.ResponseMessage;
import com.example.backend.service.DingDanDetailService;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
@Log4j
public class DingDanDetailController {

    @Autowired
    private DingDanDetailService dingDanDetailService;
    @PostMapping("/dingdandetail")
    public int doAdd(@RequestBody Car car){
        int add = dingDanDetailService.add(car);
        return add;
    }

    @DeleteMapping("/dingdandetail")
    public int doDelete(@PathVariable String order_num){

        return dingDanDetailService.deleteByOrderNum(order_num);
    }

    @GetMapping("/dingdandetail")
    public ArrayList<DingDanDetail> doQuery(){
        return dingDanDetailService.selectDingDanDetails();
        }

    @GetMapping("/dingdandetail/{dingdan_num}")
    public List<DingDanDetail> doQuery(@PathVariable String dingdan_num){
        return dingDanDetailService.selectDingDanDetailsByDingDanNum(dingdan_num);
    }

    }

